package com.sanyang.pda.presenter;

import com.sanyang.pda.bean.MovementLogBean;
import com.sanyang.pda.contract.MovementLogContract;
import com.sanyang.pda.net.NetUtils;
import com.wangshen.base.net.bean.BaseRowsAppEntity;
import com.wangshen.base.ui.mvp.base.refresh.BaseRecyclerRefreshPresenter;
import com.wangshen.base.ui.mvp.base.refresh.RequestCallback;

import java.util.List;

import io.reactivex.functions.Consumer;

public class MovementLogPresenter extends BaseRecyclerRefreshPresenter<MovementLogContract.View, MovementLogBean> implements MovementLogContract.Presenter {
    @Override
    public void onRefresh(RequestCallback<MovementLogBean> callback) {
        NetUtils.geApi().selectShiftInfoList()
                .compose(this.handleEverythingResult())
                .subscribe(new Consumer<BaseRowsAppEntity<List<MovementLogBean>>>() {
                    @Override
                    public void accept(BaseRowsAppEntity<List<MovementLogBean>> listBaseRowsAppEntity) throws Exception {
                        callback.onSuccess(listBaseRowsAppEntity.getRows());
                    }
                }, new Consumer<Throwable>() {
                    @Override
                    public void accept(Throwable throwable) throws Exception {
                        callback.onFail(throwable.getMessage());
                    }
                });
    }

    @Override
    public void onLoadMore(RequestCallback<MovementLogBean> callback) {

    }

    @Override
    public void selectShiftInfoList() {

    }
}
